home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // IMP Awards v1.0 by micmic.ifs
-
- (***************************************************
- * Movie importation script for: *
- * IMP Awards http://www.impawards.com/ *
- * *
- * (c) micmic *
- * *
- * For use with Ant Movie Catalog 3.4.2 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
-
- program micmic;
- var
- MovieName: string;
- const
- BaseURL = 'http://www.impawards.com/cgi-bin/htsearch?method=or&words=';
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: Integer;
- PosIni, PosFin: Integer;
- Line, SubLine: string;
- Title, DirURL: string;
- txtTemp: string;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
- if Pos('IMP could not find any matches for', Page.Text) > 0 then
- begin
- ShowMessage('No matches for the title search.');
- end else
- begin
- PickTreeClear;
- PickTreeAdd('Resuts for the search of "' + MovieName + '":', '');
-
- // buscamos los resultados
- LineNr := 0;
-
- while LineNr < Page.Count do
- begin
- SubLine := Page.GetString(LineNr);
- txtTemp := '<dl><dt><strong><a href="';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- //ShowMessage(IntToStr(PosIni));
- SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
-
- txtTemp := '">';
- PosFin := pos(txtTemp, SubLine);
- DirURL := Copy(SubLine, 1, PosFin - 1);
-
- SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
- txtTemp := '</a>';
- PosFin := pos(txtTemp, SubLine);
- Title := Copy(SubLine, 1, PosFin - 1);
-
- //ShowMessage(Title + '-->' + DirURL);
- PickTreeAdd(Title, DirURL);
- end;
- LineNr := LineNr + 1;
- end;
-
- Page.Free;
- if PickTreeExec(Address) then
- AnalyzeMoviePage(Address);
- end;
- end;
-
-
- procedure AnalyzeMoviePage(Address: string);
- var
- Page: TStringList;
- PosIni, PosFin: Integer;
- dirBase: string;
- txtTemp: string;
- ImgTMP: string;
- begin
- Page := TStringList.Create;
- Page.Text := StringReplace(GetPage(Address), '<br>', #13#10);
-
- //obtenemos directorio base
- PosFin := 0;
- dirBase := Address;
- PosIni := pos('/', dirBase);
- while PosIni > 0 do
- begin
- PosFin := PosFin + PosIni;
- dirBase := Copy(dirBase, PosIni + 1, Length(DirBase));
- PosIni := pos('/', dirBase);
- end;
- dirBase := Copy(Address, 1, PosFin);
-
- //buscamos la imagen
- txtTemp := '<img SRC="posters/';
- PosIni := pos(txtTemp, Page.Text);
- if PosIni > 0 then
- begin
- txtTemp := Copy(Page.Text, PosIni + Length(txtTemp), 100);
- PosFin := pos('"', txtTemp);
- ImgTMP := Copy(txtTemp, 1, PosFin - 1);
-
- GetPicture(dirBase + 'posters/' + ImgTMP, False);
- end;
-
- Page.Free;
- DisplayResults;
- end;
-
- // bmicmic: Bucle Principal
- begin
- if CheckVersion(3,4,0) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- Input('Import of IMP Awards', 'Enter the title of the movie:', MovieName);
- AnalyzePage(BaseURL + UrlEncode(MovieName));
-
- end else
- ShowMessage('This scripts requires a new version of Ant Movie Catalog (at least the version 3.4.2)');
- end.
-